package com.juyu.miliao.api.dao.mysql;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.juyu.miliao.api.domain.GiftSpend;

@Repository
public class GiftSpendDao {
	@Autowired
	private SqlSession sqlSession;
	
	public int insertGiftSpend(GiftSpend entity){
		return sqlSession.insert("insertGiftSpend", entity);
	}

	public List<GiftSpend> findGiftSpendByInUserId(int userId, int startNum, int pageSize){
		Map<String, Object> params = new HashMap<>();
		params.put("userId", userId);
		params.put("startNum", startNum);
		params.put("pageSize", pageSize);
		return sqlSession.selectList("findGiftSpendByInUserId", params);
	}

	public GiftSpend getGiftSendInfoBySendId(int sendId) {
		return sqlSession.selectOne("getGiftSendInfoBySendId",sendId);
	}

	public List<GiftSpend> getGiftSendList(){
		return sqlSession.selectList("getGiftSendList");
	}

	public List<GiftSpend> gitGiftSpendByInUserId(long userId) {
		return sqlSession.selectList("gitGiftSpendByInUserId", userId);
	}

	public List<GiftSpend> getUserGiftList(long userId, int giftId, Integer startNum, Integer pageSize) {
		Map<String, Object> params = new HashMap<>();
		params.put("userId", userId);
		params.put("giftId", giftId);
		params.put("startNum", startNum);
		params.put("pageSize", pageSize);
		return sqlSession.selectList("getUserGiftList",params);
	}
}
